# -*- coding: utf-8 -*-
"""
Created on Thu May  4 17:25:14 2017

@author: qiang.qian
"""

from ftplib import FTP 
from ftplib import FTP_TLS
import ftplib
import os
 

def ftp_down(filename = "20120904.rar"): 
    
    ftp=FTP_TLS()
    ftp.connect('dataexchange.ctrip.com',53233,60)
    ftp.set_debuglevel(2) 
    #ftp.connect('dataexchange.ctrip.com','53233') 
    ftp.login('data_ctrip_cf','qX3yHHc0CFoovsn9ynjT') 
    #print ftp.getwelcome()#显示ftp服务器欢迎信息 
    ftp.cwd('xfjr_sbu/ctrip/may_data/') #选择操作目录 
    #ftp.dir()
    
    
    
    os.chdir(r"b:")
    filename = "may_data_order_20170608.txt" 
    ftp.storbinary("STOR " + filename, open(filename, 'rb'))
    
    ftp.set_debuglevel(0) 
    ftp.quit() 
    print("ftp down OK" )
    
ftp_down()